
export const tableList = {
  data(){
    return {
    
    }
  },
  created() {
    // this.userName = this.$store.state.user.nickName;
  },
  methods: {
    getSummaries(param) {
      const {columns, data} = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        }
        let sindex = this.summaryColumn.findIndex(v => v === column.property);
        if (sindex !== -1) {
          const values = data.map(item => Number(item[column.property]));
          if (!values.every(value => isNaN(value))) {
            sums[index] = values.reduce((prev, curr) => {
              const value = Number(curr);
              if (!isNaN(value)) {
                return prev + curr;
              } else {
                return prev;
              }
            }, 0);
          }
        }
        if (sums[index]) {
          sums[index] = this.$utils.commafy(sums[index], {digits: 2, spaceNumber: 3, separator: ','})
        }
      });
      
      return sums;
    }
  }
  
}
